<html>
<head>
<?php 
		require_once '../Pages/imports.php';
	?>
<script src="../Scripts/jquery-te-1.4.0.min.js"></script>
<link href="../Styles/jquery-te-1.4.0.css" media="screen" type="text/css" rel="stylesheet"/>
<script>
$(document).ready(function(){
	$("textarea").jqte();
});
</script>
</head>
<body>
	<?php 
		require_once '../Pages/header.php';
	?>
	<div id="content">
		<h2 id="contentTitle">Modifier une news</h2>
		<a href="adminNews.php">Ajouter news</a><br/>
	<form action="modifyNews.php" method="post">
		<label>News_id </label><input type="text" id="news_id" name="news_id"/>
		<input type="submit" value="Get news"/>
	</form>
	<form action="../Scripts/modifyNewsById.php" method="post">
		<table>
		<?php
			if(isset($_POST["news_id"])){
				require_once '../Scripts/connect.php';
				$sth = $pdo->query("select * from news where news_id=".$_POST["news_id"]."");
				$result = $sth->fetchAll();
				foreach ($result as $row){
					echo '
					 		<tr>
								<td><label>Title</label></td><td><input type="text" id="title" value="'.$row["title"].'" name="title" size="100"/></td>
							</tr>
							<tr>
								<td><label>Summary</label></td><td><textarea id="summary" name="summary" cols="74" rows="10">'.$row["summary"].'</textarea></td>
							</tr>
							<tr>
								<td><label>Content</label></td><td><textarea id="newsContent" name="newsContent" cols="74" rows="20">'.$row["content"].'</textarea></td>
							</tr>
							<tr>
								<td><label>Image URL</label></td><td><input type="text" id="image" value="'.$row["image"].'" name="image" size="100"/></td>
							</tr>
							<tr>
								<td><label>News id</label></td><td><input type="text" id="news_id" value="'.$row["news_id"].'" name="news_id"/></td>
							</tr>';
				}
			}
		?>
			<tr>
				<td><label>Category</label></td><td>
									<select name="category" id="category">
										<option value="video games">video games</option>
										<option value="films">films</option>
										<option value="astuces">astuces</option>
										<option value="findings">findings</option>
									</select>
									
									</td>
			</tr>
			<tr>
				<td><label>Password</label></td><td><input type="password" id="password" name="password"/></td>
			</tr>
			<tr align="right">
				<td colspan="2"><input type="submit" value="Modifier news"/></td>
			</tr>
		</table>
	</form>
	
	<br/><br/>
	</div>
	
	<?php 
		require_once '../Pages/footer.php';
	?>
</body>
</html>